package com.alibaba.citrus.cr.common.enums.ordercenter;

import org.apache.commons.lang.StringUtils;

import java.util.Arrays;
import java.util.Objects;

public enum SalesOrderActivityTypeEnum {
    BUY_GIFT("ZS01","买赠"),
    TAKE_GIFT("ZS02","搭赠"),
    SPECIAL_OFFER_PRICE("ZS03","特价"),
    REPLENISHMENT("ZS42","补货"),
    GUNDOLA_DISPLAY("ZS11","端架陈列"),
    TRY_DRINK("ZS30","试饮"),
    DISPLAY_REPLENISHMENT("ZS15","陈列货补"),
    COUPON("COUPON","优惠券活动"),
    ;

    /**
     * 业态类型名称
     */
    private String desc;
    /**
     * 业态类型编码
     */
    private String code;

    SalesOrderActivityTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public static SalesOrderActivityTypeEnum of(String code) {
        return Arrays.stream(SalesOrderActivityTypeEnum.values()).filter(source -> StringUtils.equals(code, source.getCode())).findFirst().orElse(null);
    }

    public static String descByCode(String code) {
        SalesOrderActivityTypeEnum typeEnum = of(code);
        return Objects.nonNull(typeEnum) ? typeEnum.getDesc() : null;
    }

}
